﻿<%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="java.util.Hashtable"%>
<%@page import="com.lmpop.trade.ti_custcomment.Ti_custcommentInfo"%>
<%@page import="java.util.List"%>
<%@page import="com.lmpop.frame.util.PageTools"%>
<%@page import="com.lmpop.trade.ti_user.Ti_userInfo"%>

<%
	String showdiv = "";
	if (request.getParameter("show") != null) {
		showdiv = request.getParameter("show");
	}
		String user_id="",user_type="";
	if(session.getAttribute("session_user_id")!=null){
		user_id = session.getAttribute("session_user_id").toString();
	}
	if(session.getAttribute("session_user_type")!=null){
		user_type = session.getAttribute("session_user_type").toString();
	}
	String goods_id = "";
	if(request.getParameter("goods_id")!=null){
		goods_id = request.getParameter("goods_id");
	}

	if (!showdiv.equals("div2")) {%>
		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>商品评论</title>
<meta http-equiv="x-ua-compatible" content="ie=7" />
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<SCRIPT src="/js/thickbox/thickbox.js"></SCRIPT>
</head>
<body>
<script>
	
	function formSub(){
		
	
		if(document.getElementById('user_type').value!='0'&&document.getElementById('user_type').value!='2'){
			alert('您的用户组不允许评论！');
			
			return false;
		}
		
		if(document.getElementById('content1').value==''){
			alert('请输入评论内容！');
			document.getElementById('content1').focus();
			return false;
		}
		if(document.getElementById('userrand').value==''){
			alert('请输入验证码！');
			document.getElementById('userrand').focus();
			return false;
		}
		//alert('您的评价信息稍后会显示在这里！');
		
		document.loginForm.submit();
	}
	
	document.onkeydown = keyDown;
		
	function keyDown(e){ 
		if((e ? e.which : event.keyCode)==13 ){
				return formSub();
		}

	
	}
</script>	
<jsp:useBean id="bean" class="com.lmpop.frame.util.RandomID" scope="page" />
<%
	String info_id = bean.GenTradeId();
%>
		<p style="float:right;"><a href="#" onclick="location.reload();">关闭</a></p>
		<p>商品评价</p>

			 	<form action="/doTradeReg.do" method="post" name="loginForm">
			 		
			 	   <textarea name="content" id="content1" cols="50" rows="4" onkeydown="if(this.value.length>300){this.value=this.value.substring(0,300);}" style="font-size:12px;"></textarea><br/><br/>
				   
				   星级：<input type="radio" name="info_level" value="1" /><img src="/templets/html/shop/images/qy_xx1.jpg" />&nbsp;

				   <input type="radio" name="info_level" value="2" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" />&nbsp;


				   <input type="radio" name="info_level" value="3" checked /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" />&nbsp;

				   <input type="radio" name="info_level" value="4" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" />&nbsp;

				   <input type="radio" name="info_level" value="5" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" /><img src="/templets/html/shop/images/qy_xx1.jpg" />

				   <br/>

				   验证码：<input type="text" value="" name="userrand" id="userrand" size="10" maxlength="4" style="margin-top:12px;padding:2px"/>
				   <IMG  id="checkImage_img" src="/checkImage" onClick="changeCode()"  style="vertical-align:middle;"/><br/>
					<script language="javascript">
						function changeCode(){
						 	var dt = new Date();
						  	var randomnum = Math.random();
						 	document.getElementById("checkImage_img").src= "/checkImage"+'?'+randomnum;
						}
					</script>
					<input type="hidden" name="info_id" value="<%=goods_id%>" />
					<input type="hidden" name="info_type" id="info_type" value="goods" />
					<input type="hidden" name="goods_id" value="<%=goods_id%>" />
					<input type="hidden" name="com_type" value="0" />
					<input type="hidden" name="user_type" id="user_type" value="<%=user_type%>" />
					<input type="hidden" name="up_num" value="0" />
					<input type="hidden" name="down_num" value="0" />
					<input type="hidden" name="user_id" value="<%=user_id%>" />
				   <input name="comm" type="button" value="提   交" class="text_btn_comment" onclick="return formSub()"/>			
				   <input type="hidden" name="bpm_id" value="0674"/>
				  
				</form>	
				</body>
</html>
<%} else {
		Hashtable params = new Hashtable();
		params.put("goods_id", goods_id);
		params.put("com_type", "0");
		Ti_custcommentInfo ti_custcommentInfo = new Ti_custcommentInfo();
		String iStart = "0";
		int limit = 20;
		if (request.getParameter("iStart") != null)
			iStart = request.getParameter("iStart");

		List list = ti_custcommentInfo.getListByPage(params,
				Integer.parseInt(iStart), limit);
		int counter = ti_custcommentInfo.getCountByObj(params);

		String pageString = new PageTools().getGoogleToolsBar(counter,
				"goodsComment.jsp?iStart=", Integer.parseInt(iStart),
				limit);
		Ti_userInfo userInfo = new Ti_userInfo();

		if (list != null && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				Hashtable map = (Hashtable) list.get(i);
				String info_id = "", com_type = "", content = "", in_date = "", info_level = "", user_name = "";
				if (map.get("info_id") != null)
					info_id = map.get("info_id").toString();
				if (map.get("goods_id") != null)
					goods_id = map.get("goods_id").toString();
				if (map.get("com_type") != null)
					com_type = map.get("com_type").toString();
				if (map.get("content") != null)
					content = map.get("content").toString();
				if (map.get("in_date") != null) {
					in_date = map.get("in_date").toString();
					if (in_date.length() > 19)
						in_date = in_date.substring(0, 10);
				}

				if (map.get("user_id") != null) {
					user_id = map.get("user_id").toString();
					user_name = userInfo
							.getPersonalNameByUserId(user_id);
					if (user_name == null || "".equals(user_name))
						user_name = "匿名";
				}
				if (map.get("info_level") != null)
					info_level = map.get("info_level").toString();
				if (content.length() > 50)
					content = content.substring(0, 50) + "...";
				%>
				document.write('<div class="comment_zz"><p class="comment_zz_p">会员名：');
				document.write('<span><%=user_name %></span>');	
				document.write('</p><p class="comment_zz_p1"><%=content %></p></div>');				

					<%
						}
		}
	}
%>



